package com.pxl.bi.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pxl.bi.model.entity.Chart;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 彭显良
* @description 针对表【chart(图表信息表)】的数据库操作Mapper
* @createDate 2024-03-11 20:53:45
* @Entity generator.domain.chart
*/
public interface ChartMapper extends BaseMapper<Chart> {

    boolean insertChartData(Chart chart);

    String queryChartData(Long chartId);

    @Select("SELECT chart.*, chart_data.chartData\n" +
            "FROM chart\n" +
            "LEFT JOIN chart_data ON chart.id = chart_data.chartId\n" +
            "WHERE isDelete = 0\n" +
            "ORDER BY createTime DESC\n" +
            "LIMIT #{limitNums} OFFSET #{start}\n")
    @ResultType(Chart.class)
    List<Chart> pageChartData(@Param("limitNums") long limitNums, @Param("start") long start);

    @Select("select chartData from chart_data where chartId =#{chartId}")
    String getChartDataById(long chartId);
}




